package kit.edu.lego.gruppe3;

import kit.edu.lego.gruppe3.bluetooth.btracestarter.BTRaceStartClient;

import kit.edu.lego.gruppe3.levels.LevelSolver;

import kit.edu.lego.gruppe3.levels.bridge.BridgeSolver;
import kit.edu.lego.gruppe3.levels.door.DoorSolver;
import kit.edu.lego.gruppe3.levels.endzone.EndzoneSolver;
import kit.edu.lego.gruppe3.levels.fallingBridge.FallingBridgeSolver;
import kit.edu.lego.gruppe3.levels.labyrinth.LabyrinthSolver;
import kit.edu.lego.gruppe3.levels.line.LineSolver;
import kit.edu.lego.gruppe3.levels.rollbridge.RollBridgeSolver;
import kit.edu.lego.gruppe3.levels.rotateBridge.RotateBridgeSolver;
import kit.edu.lego.gruppe3.levels.sumpf.SumpfSolver;
import kit.edu.lego.gruppe3.levels.treeArea.TreeAreaSolver;

import kit.edu.lego.gruppe3.sensors.Scanner;

import lejos.nxt.LCD;

public class LegoMain {

	public static void main(String[] args) {

		solvers = new LevelSolver[] { btStarter, labyrinthSolver, sumpfSolver,
				lineSolver, rollBridgeSolver, firstDoorSolver, treeAreaSolver, 
				bridgeSolver, fallingBridgeSolver , rotatingBridgeSolver, endZoneSolver};

		Scanner.setup(-90);

		StartMenue.main(solvers.length);




	}

	private static char lastTurn = "l".charAt(0);
	private static LevelSolver[] solvers;

	private static int currentSolverIndex = 0;
	public static void startRollBridge() {
		rollBridgeSolver.start();
	}

	private static LevelSolver lineSolver = new LineSolver();
	private static LevelSolver bridgeSolver = new BridgeSolver();
	private static LevelSolver labyrinthSolver = new LabyrinthSolver();
	private static LevelSolver rotatingBridgeSolver = new RotateBridgeSolver();
	private static LevelSolver rollBridgeSolver = new RollBridgeSolver();
	private static LevelSolver sumpfSolver = new SumpfSolver();
	private static LevelSolver treeAreaSolver = new TreeAreaSolver();
	private static LevelSolver btStarter = new BluetoothStarter();
	private static LevelSolver firstDoorSolver = new DoorSolver();
	private static LevelSolver fallingBridgeSolver = new FallingBridgeSolver();
	private static LevelSolver endZoneSolver = new EndzoneSolver();
	
	public static void startEndZoneSolver(){
		endZoneSolver.start();
	}

	public static void startFirstDoorSolver() {
		firstDoorSolver.start();
	}

	public static void startRotatingBridge() {
		rotatingBridgeSolver.start();
	}

	public static void startFallingBridge() {
		fallingBridgeSolver.start();
	}

	public static void startLine() {
		lineSolver.start();
	}

	public static void startLabyrinth() {

		labyrinthSolver.start();
	}

	public static void startBridge() {
		bridgeSolver.start();
	}

	public static void startSumpf() {

		sumpfSolver.start();
	}

	public static char getLastTurn() {
		return lastTurn;
	}

	public static void setLastTurn(char lT) {
		lastTurn = lT;
	}

	public static void startTreeArea() {
		treeAreaSolver.start();
	}

	public static String getLevel(int i) {
		return solvers[i - 1].toString();
	}

	public static void startSolver(int i) {
		LCD.refresh();
		// LCD.drawString("starting " + solvers[i-1].toString(), 2, 2);
		currentSolverIndex = (i - 1);
		solvers[i - 1].start();
	}

	public static void startNextSolver() {
		LCD.refresh();
		currentSolverIndex += 1;
		LCD.drawString("starting " + solvers[currentSolverIndex].toString(), 2, 2);
		solvers[currentSolverIndex].start();
	}

	
}
